<?php

namespace iBrand\Component\Purchase;

use iBrand\Component\Purchase\Repositories\Eloquent\PurchaseItemRepositoryEloquent;
use iBrand\Component\Purchase\Repositories\Eloquent\PurchaseRepositoryEloquent;
use iBrand\Component\Purchase\Repositories\Eloquent\StockRecordRepositoryEloquent;
use iBrand\Component\Purchase\Repositories\Eloquent\TakeStockItemRepositoryEloquent;
use iBrand\Component\Purchase\Repositories\Eloquent\TakeStockRepositoryEloquent;
use iBrand\Component\Purchase\Repositories\Eloquent\TransferItemRepositoryEloquent;
use iBrand\Component\Purchase\Repositories\Eloquent\TransferRepositoryEloquent;
use iBrand\Component\Purchase\Repositories\PurchaseItemRepository;
use iBrand\Component\Purchase\Repositories\PurchaseRepository;
use iBrand\Component\Purchase\Repositories\StockRecordRepository;
use iBrand\Component\Purchase\Repositories\TakeStockItemRepository;
use iBrand\Component\Purchase\Repositories\TakeStockRepository;
use iBrand\Component\Purchase\Repositories\TransferItemRepository;
use iBrand\Component\Purchase\Repositories\TransferRepository;
use Illuminate\Support\Facades\Event;
use Illuminate\Support\ServiceProvider;

class PurchaseServiceProvider extends ServiceProvider
{
	protected $subscribe = [
		'iBrand\Component\Purchase\Listeners\StockChangedListener',
	];

	public function boot()
	{
		if ($this->app->runningInConsole()) {
			$this->loadMigrationsFrom(__DIR__ . '/../migrations');
		}

		foreach ($this->subscribe as $item) {
			Event::subscribe($item);
		}
	}

	public function register()
	{
		$this->app->bind(PurchaseRepository::class, PurchaseRepositoryEloquent::class);

		$this->app->bind(StockRecordRepository::class, StockRecordRepositoryEloquent::class);

		$this->app->bind(PurchaseItemRepository::class, PurchaseItemRepositoryEloquent::class);

		$this->app->bind(TakeStockRepository::class, TakeStockRepositoryEloquent::class);

		$this->app->bind(TakeStockItemRepository::class, TakeStockItemRepositoryEloquent::class);

		$this->app->bind(TransferRepository::class, TransferRepositoryEloquent::class);

		$this->app->bind(TransferItemRepository::class, TransferItemRepositoryEloquent::class);
	}

}